package com.huawei.petapp2.call;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.huawei.petapp2.entity.Result;
import com.huawei.petapp2.entity.Shoppingcart;
import com.huawei.petapp2.utils.DateUtil;
import com.zhy.http.okhttp.callback.Callback;

import java.io.IOException;
import java.util.List;

import okhttp3.Response;

public abstract class ShoppingcartCallback extends Callback<List<Shoppingcart>>
{

    //非UI线程，支持任何耗时操作
    final private static Gson gson=new GsonBuilder().serializeNulls().create();

    @Override
    public List<Shoppingcart> parseNetworkResponse(Response response,int id) throws IOException
    {
        List<Shoppingcart> shoppingcarts;
        String string = response.body().string();
        Result result=gson.fromJson(string,Result.class);
        System.out.println("新的获取订单请求请求OnintView"+result);
        shoppingcarts= DateUtil.getList10(result);
        return shoppingcarts;
    }

}
